package com.fare.taluo.auth.domain;

import java.util.Date;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.auth.domain.repository.IUserInfoRepository;
/**
 * 用户信息
 * @author xiangsf 2014-04-29
 *
 */
@Entity
@Table(name="sys_userinfo")
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class UserInfoEntity extends com.fare.taluo.base.ddd.domain.baseentity.BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 9063438774040129721L;

	@Column(name="ACCOUT_id")
	private Long accoutId;//对应的用户标识表ＩＤ
	
	@Column(name="login_id")
	private String loginId;//登陆名
	
	@Column(name="name")
	private String name;//姓名
	
	@Column(name="create_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime = new Date();//创建时间
	
	@Column(name="sex")
	private String sex;//性别
	
	@Column(name="email")
	private String email;//邮箱
	
	@Column(name="mobile")
	private String mobile;//手机
	
	@Column(name="telephone")
	private String telephone;//电话

	@Column(name="qq")
	private String qq;//QQ
	
	@Column(name="remark")
	private String remark;//QQ
	/**
	 * 排序号
	 */
	@Column(name = "PRIORITY")
	protected Integer priority = 0;
	/**
	 * 所属航空公司或渠道ID
	 */
	@Column(name="source_id")
	private Long sourceId;
	
	@Column(name="source_name")
	private String sourceName;
	
	@Column(name="source_key")
	private String sourceKey;
	
	
	
	private static IUserInfoRepository getRepository(){
		return InstanceFactory.getInstance(IUserInfoRepository.class);
	}
	
	public Boolean queryIsExist(Long ids,String email,String username) {
		return getRepository().queryIsExist(ids, email, username);
	}
	public void saveOrUpate(UserInfoEntity entity){
		getRepository().saveOrUpate(entity);
	}
	
	public Long getAccoutId() {
		return accoutId;
	}
	public void setAccoutId(Long accoutId) {
		this.accoutId = accoutId;
	}
	public String getLoginId() {
		return loginId;
	}
	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getTelephone() {
		return telephone;
	}
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	public String getQq() {
		return qq;
	}
	public void setQq(String qq) {
		this.qq = qq;
	}
	
	public Long getSourceId() {
		return sourceId;
	}
	public void setSourceId(Long sourceId) {
		this.sourceId = sourceId;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public Integer getPriority() {
		return priority;
	}
	public void setPriority(Integer priority) {
		this.priority = priority;
	}
	
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	public String getSourceName() {
		return sourceName;
	}
	public void setSourceName(String sourceName) {
		this.sourceName = sourceName;
	}
	public String getSourceKey() {
		return sourceKey;
	}
	public void setSourceKey(String sourceKey) {
		this.sourceKey = sourceKey;
	}
	
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((sourceId == null) ? 0 : sourceId.hashCode());
		result = prime * result
				+ ((createTime == null) ? 0 : createTime.hashCode());
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result + ((loginId == null) ? 0 : loginId.hashCode());
		result = prime * result + ((mobile == null) ? 0 : mobile.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((priority == null) ? 0 : priority.hashCode());
		result = prime * result + ((qq == null) ? 0 : qq.hashCode());
		result = prime * result + ((sex == null) ? 0 : sex.hashCode());
		result = prime * result
				+ ((telephone == null) ? 0 : telephone.hashCode());
		result = prime * result + ((accoutId == null) ? 0 : accoutId.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserInfoEntity other = (UserInfoEntity) obj;
		if (sourceId == null) {
			if (other.sourceId != null)
				return false;
		} else if (!sourceId.equals(other.sourceId))
			return false;
		if (createTime == null) {
			if (other.createTime != null)
				return false;
		} else if (!createTime.equals(other.createTime))
			return false;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (loginId == null) {
			if (other.loginId != null)
				return false;
		} else if (!loginId.equals(other.loginId))
			return false;
		if (mobile == null) {
			if (other.mobile != null)
				return false;
		} else if (!mobile.equals(other.mobile))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (priority == null) {
			if (other.priority != null)
				return false;
		} else if (!priority.equals(other.priority))
			return false;
		if (qq == null) {
			if (other.qq != null)
				return false;
		} else if (!qq.equals(other.qq))
			return false;
		if (sex == null) {
			if (other.sex != null)
				return false;
		} else if (!sex.equals(other.sex))
			return false;
		if (telephone == null) {
			if (other.telephone != null)
				return false;
		} else if (!telephone.equals(other.telephone))
			return false;
		if (accoutId == null) {
			if (other.accoutId != null)
				return false;
		} else if (!accoutId.equals(other.accoutId))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "UserInfoEntity [accoutId=" + accoutId + ", loginId=" + loginId
				+ ", name=" + name + ", createTime=" + createTime + ", sex="
				+ sex + ", email=" + email + ", mobile=" + mobile
				+ ", telephone=" + telephone + ", qq=" + qq + ", priority="
				+ priority + ", sourceId=" + sourceId + "]";
	}

	
	
	
}
